function addLoadEvent(func){
	var oldonload = window.onload;
	if(typeof window.onload != 'function'){
		window.onload = func;
	}else{
		window.onload = function(){
			oldonload();
			func();
		}
	}

}


function moveElement(elementID,final_x,final_y,interval){
	var elem = document.getElementById(elementID);
	if(!elem.style.left){
		elem.style.left = "0px";
	}
	if(!elem.style.top){
		elem.style.top = "0px";
	}
	if(elem.moveElement){
		clearTimeout(elem.moveElement);
	}

	var xpos = parseInt(elem.style.left);
	var ypos = parseInt(elem.style.top);
 	var dist = 0;
 	if(xpos == final_x && ypos == final_y){
 		return true;
 	}
 	if(xpos < final_x){
 		dist = Math.ceil((final_x - xpos)/10);
 		xpos = xpos + dist;
 	}
 	if(xpos > final_x){
 		dist = Math.ceil((xpos - final_x)/10);
 		xpos = xpos - dist;
 	}
 	if(ypos < final_y){
 		dist = Math.ceil((final_y - ypos)/10);
 		ypos = ypos + dist;
 	}
 	if(ypos > final_y){
 		dist = Math.ceil((ypos - final_y)/10);
 		ypos = ypos - dist;
 	}
 	elem.style.left = xpos + "px";
 	elem.style.top = ypos + "px";

 	var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")";
 	elem.moveElement = setTimeout(repeat,interval);
}


function slideShow(){
	if(!document.getElementById) return false;
	if(!document.getElementsByTagName) return false;
	var img= document.getElementById("img");
	img.style.position = "absolute";
	console.log(img);

	var list = document.getElementById("linklist");
	var link = list.getElementsByTagName("a");

	link[0].onmouseover = function(){
		moveElement("img",0,0,10);
	}
	link[1].onmouseover = function(){
		moveElement("img",-200,0,10);
	}
	link[2].onmouseover = function(){
		moveElement("img",-400,0,10);
	}
	link[3].onmouseover = function(){
		moveElement("img",-600,0,10);
	}
	
}

addLoadEvent(slideShow);
















